<?php
#############################################################################
# Parse functions for http://etvnet.com site.                               #
#                                                                           #
# Author: consros 2010                                                      #
#############################################################################

require_once "pageTools.inc";
require_once "settings.inc";
require_once "tools.inc";
require_once "etvFunctions.inc";
require_once "parsers.inc";
require_once "links.php";
require_once "video.php";

define("DEBUG", false);

displayHtmlHeader("NMT support for eTVnet");
displayLinkStyles();
displayVideoStyles();

displayHtmlBody("DEFAULTREF");
displayTopNavigation();

$path = '/catalog/';
if (isset($_GET['search'])) {
    $path = '/search/?q=' . urlencode($_GET['search']);
    addToHistory("history/search.txt", $_GET['search'], $_GET['search']);
} elseif (isset($_GET['path'])) {
    $path = urldecode($_GET['path']);
} elseif (isset($_SESSION['path'])) {
    $path = $_SESSION['path'];
}
if (isset($_GET['opts'])) {
    $path .= '?' . urldecode($_GET['opts']);
}
$_SESSION['path'] = $path;

if (DEBUG) {
    print "<textarea cols=80 rows=10>";
}

$functions = new EtvFunctions(DEBUG);
$html = $functions->getStreamPage($path);
$html = compactHtml($html);

if (DEBUG) {
    print "</textarea><br /><br />\n\n";
}

if (! isVideoPage($html)) {
    displayLinksPage($html, $path);
} else {
    displayVideoPage($html, $path);
}

displayHtmlEnd();
?>
